<!DOCTYPE html>
<html>

<head lang='zh'>
    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=0" />
    <title>Luckysheet</title>

    <script src="./assets/data-mgr.js"></script>

    <link rel='stylesheet' href='./plugins/css/pluginsCss.css' />
    <link rel='stylesheet' href='./plugins/plugins.css' />
    <link rel='stylesheet' href='./css/luckysheet.css' />
    <link rel='stylesheet' href='./assets/iconfont/iconfont.css' />
    <script src="./plugins/js/plugin.js"></script>

    <!-- rollup luckysheet.js -->
    <script src="./luckysheet.umd.js"></script>


</head>

<body>
    <!-- Non-full screen test -->
    <!-- <div style="position: relative;width: 100%;height: 100%;">

		<div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:80%;height:500px;left: 20%;top: 200px;bottom:0;right: 0;"></div>
	</div> -->
    <div>
        <button onclick="getSheet()">表格参数</button>
        <button onclick="show()">显示格线</button>
        <button onclick="hide()">隐藏格线</button>
        <button onclick="print()">打印测试</button>
        <button onclick="setRangeFormat()">设置只读</button>
        <input id="uploadBtn" type="file" />
        <button onclick="exportExcel()">导出</button>
        <button onclick="ds2cells(window.luckysheet)">ds2cells</button>
    </div>
    </div>
    <div id="luckysheet" style="margin:0px;padding:0px;width:100%;height:700px;left: 0px;top: 0px;"> </div>
    <div id="print_html" style="border:1px solid red;padding: 5px;"></div>

    <script>
        window.luckysheet.create({
            container: 'luckysheet', //luckysheet is the container id
            // showinfobar: false,
            // showtoolbar: false,
            // showsheetbar: false,
            fullscreenmode: false,
            // sheetFormulaBar: false,
            // allowEdit: false,
            // plugins: [{ name: 'chart' }],
            column: 10,
            row: 100
        });
        console.log("options", window.luckysheet.getOptions())
        function getSheet() {
            console.log("表格参数", window.luckysheet.getAllSheets())
        }
        function hide() {
            window.luckysheet.hideGridLines();
        }
        function show() {
            window.luckysheet.showGridLines();
        }
        function print() {
            console.log("start print")
            window.luckysheet.getScreenshotNew(function (res) {
                const $img = `<img src=${res} style="max-width: 100%;" />`
                document.querySelector('#print_html').innerHTML = $img
            })
        }
        function setRangeFormat() {
            window.luckysheet.setRangeFormat("ro", true)
        }
        function exportExcel() {
            let cb = function (data) {
                console.log(data)
            }
            let ll = window.luckysheet.export2Excel(cb);
            console.log(ll)
        }
        // 获取文件输入元素
        const uploadBtn = document.getElementById('uploadBtn');
        // 监听 change 事件
        uploadBtn.addEventListener('change', function (event) {
            loadExcel(event)
        });

        function loadExcel(evt) {
            window.luckysheet.loadExcel(evt)
        }
    </script>
    <style>
        /* 自定义loading演示样式 */
        @keyframes loading-rotate {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        @keyframes loading-dash {
            0% {
                stroke-dasharray: 1, 200;
                stroke-dashoffset: 0;
            }

            50% {
                stroke-dasharray: 90, 150;
                stroke-dashoffset: -40px;
            }

            100% {
                stroke-dasharray: 90, 150;
                stroke-dashoffset: -120px;
            }
        }

        .loadingAnimation {
            width: 3em;
            height: 3em;
            animation: loading-rotate 2s linear infinite;
        }

        .loadingAnimation circle {
            animation: loading-dash 1.5s ease-in-out infinite;
            stroke-dasharray: 90, 150;
            stroke-dashoffset: 0;
            stroke-width: 2;
            stroke: currentColor;
            stroke-linecap: round;
        }
    </style>
</body>

</html>